/**
 * 
 */
package com.feonix.designPattern.bridge.sample1;

/**
 * @CopyRight (c)1993-2017
 * @Project common_practice
 * @Comments 请输入该类的描述
 * @NameSpace com.feonix.designPattern.bridge.sample1
 * @Author Feonixzw
 * @CreateDate 2018年2月5日
 */
public class StringDisplayImpl extends Display {

	private String str;

	private int width;

	public StringDisplayImpl(String str) {
		this.str = str;
		this.width = str.getBytes().length;
	}

	@Override
	public void rawOpen() {
		printLine();
	}

	@Override
	public void rawPrint() {
		System.out.println("|" + this.str + "|");

	}

	@Override
	public void rawClose() {
		printLine();
	}

	/**
	 * 
	 */
	private void printLine() {
		System.out.print("+");
		for (int i = 0; i < this.width; i++) {
			System.out.print("-");
		}
		System.out.println("+");
	}

}
